//
//  ViewController.m
//  RSegement
//
//  Created by Zin_戦 on 2018/2/6.
//  Copyright © 2018年 Zin_戦. All rights reserved.
//

#import "ViewController.h"
#import "RSegement.h"
/** 屏幕尺寸参数 */
#define kSCREEN_WIDTH        ([UIScreen mainScreen].bounds.size.width)
#define kSCREEN_HEIGHT       ([UIScreen mainScreen].bounds.size.height)
@interface ViewController ()<CurrentIndexDelegete>
@property(nonatomic, strong) RSegement   *header;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor grayColor];
    _header = [[[NSBundle mainBundle] loadNibNamed:@"RSegement" owner:self options:nil] lastObject];
    _header.frame = CGRectMake(0, 40,kSCREEN_WIDTH , 49);
    [RSegement setBadgeNumber:3 buttonItem:_header.btn0];
    [RSegement setBadgeNumber:5 buttonItem:_header.btn1];
    [RSegement setBadgeNumber:7 buttonItem:_header.btn2];
    [RSegement setBadgeNumber:9 buttonItem:_header.btn3];
    [self.view addSubview:_header];
    _header.delegate = self;
    
}

- (void)selectIndex:(NSInteger)index current_btn:(UIButton *)current_btn{
    if (index == 1) {
        [RSegement setBadgeNumber:10 buttonItem:current_btn];

    }if (index == 0) {
        [RSegement setBadgeNumber:0 buttonItem:current_btn];

    }
    NSLog(@"----index = %ld--current_btn =%@",index,current_btn.currentTitle);
}
@end
